package com.gomoku;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class OnlineMenu extends JFrame {
    public OnlineMenu() {
        setTitle("联机对战菜单");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);
        setResizable(false);

        JPanel panel = new JPanel(new GridLayout(3, 1, 10, 10));
        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        JButton hostButton = new JButton("创建游戏(主机)");
        JButton joinButton = new JButton("加入游戏(客户端)");
        JButton backButton = new JButton("返回主菜单");

        hostButton.addActionListener(e -> {
            dispose();
            new HostGameFrame().setVisible(true);
        });

        joinButton.addActionListener(e -> {
            dispose();
            new JoinGameFrame().setVisible(true);
        });

        backButton.addActionListener(e -> {
            dispose();
            new MainMenu().setVisible(true);
        });

        panel.add(hostButton);
        panel.add(joinButton);
        panel.add(backButton);

        add(panel);
    }
}